import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import com.baomidou.mybatisplus.core.toolkit.Sequence;
import com.baomidou.mybatisplus.core.toolkit.StringPool;

public class IdWorker {

    /**
     * 涓绘満鍜岃繘绋嬬殑鏈哄櫒鐮�
     */
    private static Sequence WORKER = new Sequence();

    public static long getId() {
        return WORKER.nextId();
    }

    public static String getIdStr() {
        return String.valueOf(WORKER.nextId());
    }

    /**
     * <p>
     * 鏈夊弬鏋勯�犲櫒
     * </p>
     *
     * @param workerId     宸ヤ綔鏈哄櫒 ID
     * @param datacenterId 搴忓垪鍙�
     */
    public static void initSequence(long workerId, long datacenterId) {
        WORKER = new Sequence(workerId, datacenterId);
    }

    /**
     * <p>
     * 鑾峰彇鍘绘帀"-" UUID
     * </p>
     */
    public static synchronized String get32UUID() {
        return UUID.randomUUID().toString().replace(StringPool.DASH, StringPool.EMPTY);
    }
    
    public static void main(String[] args) {
    	List<Boolean> trues = new ArrayList<>();
    	/*for (int i = 0; i < 100000000; i++) {
			if(IdWorker.getId()-IdWorker.getId() < 0){
				trues.add(true);
			}
		}*/
		System.out.println(IdWorker.getId()-IdWorker.getId() < 0);
		System.out.println(IdWorker.get32UUID());
		System.out.println(trues.size());
	}
}